﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>商家管理之增加商家</title>
    <link rel="icon" href="${pageContext.request.contextPath}/static/admin/favicon.ico" type="image/ico">
    <meta name="keywords" content="后台模板,后台管理系统,HTML模板">
    <meta name="description" content="基于Bootstrap的后台管理系统模板">
    <meta name="author" content="www.bootstrapmb.com">
    <link href="${pageContext.request.contextPath}/static/admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/admin/css/fonts.css" rel="stylesheet">
    <!--标签插件-->
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/static/admin/js/jquery-tags-input/jquery.tagsinput.min.css">
    <link href="${pageContext.request.contextPath}/static/admin/css/style.css" rel="stylesheet">
</head>

<body>
<!--页面主要内容-->
<main class="ftdms-layout-content">

    <div class="container-fluid" style="height: 1200px;">

        <div class="row" style="margin-top:15px;">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body">

                        <form id="form1" action="${pageContext.request.contextPath}/admin/businessadd.action"
                              method="post" class="row">
                            <div class="form-group col-md-12">
                                <label>商家名称</label>
                                <input type="text" class="form-control" id="businessName" name="businessName" value=""
                                       placeholder="请输入标题"/>
                            </div>
                            <div class="form-group col-md-12">
                                <label>商家电话&nbsp;&nbsp;&nbsp;<b id="mess"></b></label>
                                <input type="tel" class="form-control" id="businessTel" name="businessTel" value=""
                                       placeholder="请输入标题"/>
                            </div>
                            <div class="form-group col-md-12">
                                <label>商家密码</label>
                                <input type="password" class="form-control" id="businessPass" name="businessPass"
                                       value="" placeholder="请输入标题"/>
                            </div>
                            <div class="form-group col-md-12">
                                <label>商家确认密码</label>
                                <input type="password" class="form-control" id="qbusinessPass" name="qbusinessPass"
                                       value=""
                                       placeholder="请输入标题"/>
                            </div>
                            <div class="form-group col-md-12">
                                <label>商家地址</label>
                            </div>
                            <input type="text" class="form-control" id="businessAddress" name="businessAddress" value=""
                                   placeholder="请输入标题"/>
                            <div class="form-group col-md-12">
                                <label>商家状态</label>
                                <select class="form-control" id="bStateId" name="bStateId">
                                    <c:forEach items="${businessstatelist}" var="businessstate">
                                        <option value="${businessstate.bStateId}">${businessstate.bStateName}</option>
                                    </c:forEach>

                                </select>
                            </div>
                            <div class="form-group col-md-12">
                                <input type="hidden" id="data">
                                <button type="button" onclick="myfun1()" class="btn btn-primary ajax-post"
                                        target-form="add-form">确 定
                                </button>
                                <button type="button" class="btn btn-default"
                                        onclick="javascript:history.back(-1);return false;">返 回
                                </button>
                            </div>
                        </form>

                    </div>
                </div>
            </div>

        </div>

    </div>

</main>
<!--End 页面主要内容-->
</div>
</div>

<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/js/bootstrap.js"></script>
<script type="text/javascript"
        src="${pageContext.request.contextPath}/static/admin/js/perfect-scrollbar.min.js"></script>
<!--标签插件-->
<script src="${pageContext.request.contextPath}/static/admin/js/jquery-tags-input/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/js/main.min.js"></script>
<script>
    $(function () {
        $('#businessTel').blur(function () {
            var b = $('#businessTel').val();
            console.log(b);
            $.post("${pageContext.request.contextPath}/admin/businesstel.action", {businessTel: b}, function (data) {
                console.log(data)
                var d=$("#data").val(data);
                console.log(d)
                if (data == false) {
                    $('#mess').css("color", "green")
                    $('#mess').html("该号码可用");
                }
                if (data == true) {
                    $('#mess').css("color", "red")
                    $('#mess').html("该号码已注册");
                }
            });
        });
    })
    function myfun1() {
        var d = $("#data").val();
        console.log("sadasd"+d);
        var businessName=$('#businessName').val();
        var businessTel=$('#businessTel').val();
        var businessPass=$('#businessPass').val();
        var qbusinessPass=$('#qbusinessPass').val();
        var businessAddress=$('#businessAddress').val();
        if(businessName.trim()==null||businessName.trim()==""){
            alert("商家名称不能为空");
            return;
        }  if(businessTel.trim()==null||businessTel.trim()==""){
            alert("商家电话不能为空");
            return;
        }
        if (businessPass.trim() == null || businessPass.trim() == "") {
            alert("商家密码不能为空");
            return;
        }if (qbusinessPass.trim() !=businessPass.trim()) {
            alert("两次密码不一致");
            return;
        }
        if (businessAddress.trim() == null || businessAddress.trim() == "") {
            alert("商家地址不能为空");
            return;
        }
        if (d == "true") {
            alert("账号存在不能提交");
            return;
        }
        $("#form1").submit();
    }
</script>
</body>

</html>